/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompLeaseOrderPageDTO;
import com.softtown.modules.dapai.dto.CompSaleOrderPageDTO;
import com.softtown.modules.dapai.dto.LeaseOrderAddOrUpdateDTO;
import com.softtown.modules.dapai.dto.SaleOrderAddOrUpdateDTO;
import com.softtown.modules.dapai.entity.CompLeaseOrderEntity;
import com.softtown.modules.dapai.entity.CompSaleOrderEntity;
import com.softtown.modules.dapai.service.CompLeaseOrderService;
import com.softtown.modules.dapai.service.CompSaleOrderService;
import com.softtown.modules.dapai.vo.CompLeaseOrderVO;
import com.softtown.modules.dapai.vo.CompSaleOrderVO;
import com.softtown.modules.dapai.vo.SaleOrderCustomerVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 租赁订单管理
 *
 * @author Ding Ya Yong
 */
@RestController
@RequestMapping("leaseOrder")
@Api(tags="租赁订单")
public class CompLeaseOrderController {


    @Resource
    private CompLeaseOrderService compLeaseOrderService;

    @PostMapping("getLeaseOrderPageList")
    @ApiOperation("获取租赁订单管理分页")
    public Result getLeaseOrderPageList(@RequestBody CompLeaseOrderPageDTO compLeaseOrderPageDTO) {
        PageInfo<CompLeaseOrderEntity> compLeaseOrderEntityPageInfo = compLeaseOrderService.getLeaseOrderPageList(compLeaseOrderPageDTO);
        return new Result<PageInfo<CompLeaseOrderEntity>>().ok(compLeaseOrderEntityPageInfo);
    }





    @PostMapping("getLeaseOrderById")
    @ApiOperation("获取租赁订单详情")
    public Result<CompLeaseOrderVO> getLeaseOrderById(@RequestBody CompLeaseOrderPageDTO compLeaseOrderPageDTO) {
        CompLeaseOrderVO compLeaseOrderVO = compLeaseOrderService.getLeaseOrderById(compLeaseOrderPageDTO.getCompId(),compLeaseOrderPageDTO.getId());
        return new Result<CompLeaseOrderVO>().ok(compLeaseOrderVO);
    }


    @PostMapping("addLeaseOrder")
    @ApiOperation("添加租赁订单")
    public Result addLeaseOrder(@RequestBody LeaseOrderAddOrUpdateDTO leaseOrderAddOrUpdateDTO) {
        Result result = new Result<>();
        compLeaseOrderService.addLeaseOrder(leaseOrderAddOrUpdateDTO);
        return result;
    }


    @PostMapping("updateLeaseOrder")
    @ApiOperation("编辑租赁订单")
    public Result updateLeaseOrder(@RequestBody LeaseOrderAddOrUpdateDTO leaseOrderAddOrUpdateDTO) {
        Result result = new Result<>();
        compLeaseOrderService.updateLeaseOrder(leaseOrderAddOrUpdateDTO);
        return result;
    }



    @PostMapping("deleteLeaseOrder")
    @ApiOperation("删除租赁订单")
    public Result deleteLeaseOrder(@RequestBody CompLeaseOrderPageDTO compLeaseOrderPageDTO) {
        Result result = new Result<>();
        compLeaseOrderService.deleteLeaseOrder(compLeaseOrderPageDTO.getCompId(),compLeaseOrderPageDTO.getId());
        return result;
    }




}